-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the aarch64 elf version in template file and reassemble #19871
Merged
+1
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Strange that we ever did this. Every other template specifies an
|
bcoles
approved these changes
Feb 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Untested, but the code changes make sense.
The compiled file changes match the PR description:
# hexdump -C new-template_aarch64_linux.bin > a
# hexdump -C data/templates/template_aarch64_linux.bin > b
# diff -u a b
--- a 2025-02-15 07:43:27.172159925 -0500
+++ b 2025-02-15 07:43:31.393529202 -0500
@@ -1,5 +1,5 @@
00000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............|
-00000010 02 00 b7 00 01 00 00 00 78 00 40 00 00 00 00 00 |........x.@.....|
+00000010 02 00 b7 00 00 00 00 00 78 00 40 00 00 00 00 00 |........x.@.....|
00000020 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |@...............|
00000030 00 00 00 00 40 00 38 00 01 00 00 00 00 00 00 00 |[email protected].........|
00000040 01 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 |................|
The other existing aarch64 Linux template (template_aarch64_linux_dll.bin
) already uses ELF version 1.
# readelf -h data/templates/template_aarch64_linux*
File: data/templates/template_aarch64_linux.bin
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x0
Entry point address: 0x400078
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 1
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
File: data/templates/template_aarch64_linux_dll.bin
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: AArch64
Version: 0x1
Entry point address: 0x1a0
Start of program headers: 64 (bytes into file)
Start of section headers: 176 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 2
Size of section headers: 64 (bytes)
Number of section headers: 2
Section header string table index: 1
readelf: Error: no .dynamic section in the dynamic segment
msutovsky-r7
approved these changes
Feb 18, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out we are using ELF version 0 for aarch64 staged elf payloads. There's no such version. In fact, there has ever only been version 1. See https://en.wikipedia.org/wiki/Executable_and_Linkable_Format for the value in offset 0x14.
This just sets that value to 1. It does not fix all the problems we have seen, but it does allow debuggers and other tools to work so we can figure out why it is failing.
Related:
#19841
#19865
Testing
Old
New